//
//  ViedoCollectionViewCell.m
//  B_WatchHome
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 DHF. All rights reserved.
//

#import "ViedoCollectionViewCell.h"
#import <UIImageView+WebCache.h>

#define WIDTH ([UIScreen mainScreen].bounds.size.width)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height)

@implementation ViedoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView
{
    self.backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, (173*WIDTH)/375, (150*HEIGHT)/667)];
    
    [self.contentView addSubview:self.backImageView];
    
    self.backImageView.userInteractionEnabled = YES;
    
    self.backLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, (150*HEIGHT)/667, (170*WIDTH)/375, (50*HEIGHT)/667)];
    
    self.backLabel.backgroundColor =[UIColor whiteColor];
    
    [self.contentView addSubview:self.backLabel];
    
    self.headLabel = [[UILabel alloc]initWithFrame:CGRectMake((10*WIDTH)/375, (150*HEIGHT)/667, (165*WIDTH)/375, (40*HEIGHT)/667)];
    
    self.headLabel.textColor = [UIColor blackColor];
    
    self.headLabel.numberOfLines = 2;
    
    self.headLabel.font = [UIFont boldSystemFontOfSize:12];
    
    self.headLabel.textAlignment =  NSTextAlignmentLeft;
    
    [self.contentView addSubview:self.headLabel];
    
    self.footLabel = [[UILabel alloc]initWithFrame:CGRectMake((10*WIDTH)/375, (185*HEIGHT)/667, (165*WIDTH)/375, (15*HEIGHT)/667)];
    
    self.footLabel.font = [UIFont boldSystemFontOfSize:10];
    
    self.footLabel.textColor = [UIColor blackColor];
    
    [self.contentView addSubview:self.footLabel];
    
}

- (void)setModel:(VideoModel *)model
{
    if (_model != model) {
        _model = model;
    }
    
    self.headLabel.text = [NSString stringWithFormat:@"%@",self.model.title];
    
    self.footLabel.text = [NSString stringWithFormat:@"  %@",self.model.pubdate];
    
    self.footLabel.textColor = [UIColor colorWithRed:0.90 green:0.90 blue:0.90 alpha:1.0];
    
    NSURL *url = [NSURL URLWithString:self.model.cover_thumb];
    
    [self.backImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"1.jpg"]];
}

































@end
